//
//  PKProductTableViewCell.m
//  PianKe
//
//  Created by lanou on 15/9/26.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "PKProductTableViewCell.h"
#import <UIImageView+WebCache.h>
@implementation PKProductTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _mainImageView=[[UIImageView alloc]init];
        _mainImageView.frame=CGRectMake(10, 10, SCREEN_WIDTH-20, 300*(SCREEN_WIDTH-20)/608);
        [self.contentView addSubview:_mainImageView];
        CGFloat lbY=_mainImageView.frame.size.height+20;
        _titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, lbY, 200, 20 )];
        [self.contentView addSubview:_titleLabel];
        _buyButton=[UIButton buttonWithType:UIButtonTypeCustom];
        [_buyButton setTitle:@"立即购买" forState:UIControlStateNormal];
        _buyButton.frame=CGRectMake(SCREEN_WIDTH-90, lbY, 80, 20);
        [_buyButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        
        [self.contentView addSubview:_buyButton];
    }
    return self;
}

//重写setter方法，然后在setter方法内部给cell控件赋值
-(void)setConfigureModel:(PKProductMainListModel *)configureModel
{
    _configureModel=configureModel;
    [_mainImageView sd_setImageWithURL:[NSURL URLWithString:configureModel.coverimg]];
    _titleLabel.text=configureModel.title;
}
- (void)awakeFromNib {
    // Initialization code
}
+(CGFloat )heightForCell
{
    return 300*(SCREEN_WIDTH-20)/608+10+40;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
